<?php
/*************************************************************************
Login module
----------------------------------------------------------------
Derasoft CMS Project
Company: Derasoft Co., Ltd                                  
Email: info@derasoft.com                                    
Last updated: 02/07/2008
**************************************************************************/
#login
include_once(ROOT_PATH."classes/dao/members.class.php");
include_once(ROOT_PATH."includes/functions.php");
$members = new Members();
$templateFile = "";
$status = array();
if($_POST) {
	$username = trim($request->element("username",''));
	$password = trim($request->element("password",''));
	$userId = 0;
	$status['error'] = "";
	if($username != "" && $username != ""){
		$userId = $members->authenticateUser($username,$password);
		if($userId) {
			 $_SESSION['memberId'] = $userId;
		} else {
				$_SESSION['memberId'] = '';
				$status['error'] .= "Tên đăng nhập hoặc mật khẩu không đúng";
		}
	}else{
		$status['error'] .= "Tên đăng nhập hoặc mật khẩu không được rỗng";	
	}
}
echo json_encode($status);
?>